﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Windows.Data;

namespace Ellanet.Converters
{
    public class ChoiceIsCorrectToImageConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool isCorrect;

            if (bool.TryParse(value.ToString(), out isCorrect))
            {
                var imageList = new List<string>();

                if (isCorrect)
                {
                    imageList.Add("/Resources/Minion-Amazed-icon.png");
                    imageList.Add("/Resources/Minion-Bananas-icon.png");
                    imageList.Add("/Resources/Minion-Big-icon.png");
                    imageList.Add("/Resources/Minion-Cake-icon.png");
                    imageList.Add("/Resources/Minion-Crazy-icon.png");
                    imageList.Add("/Resources/Minion-Curious-icon.png");
                    imageList.Add("/Resources/Minion-Dancing-icon.png");
                    imageList.Add("/Resources/Minion-Duck-icon.png");
                    imageList.Add("/Resources/Minion-Fruits-icon.png");
                    imageList.Add("/Resources/Minion-Girl-icon.png");
                    imageList.Add("/Resources/Minion-Happy-icon.png");
                    imageList.Add("/Resources/Minion-Hello-icon.png");
                    imageList.Add("/Resources/Minion-Kungfu-icon.png");
                    imageList.Add("/Resources/Minion-Maid-icon.png");
                    imageList.Add("/Resources/Minion-Playing-Golf-icon.png");
                    imageList.Add("/Resources/Minion-Reading-icon.png");
                    imageList.Add("/Resources/Minion-Sad-icon.png");
                    imageList.Add("/Resources/Minion-Shout-icon.png");
                    imageList.Add("/Resources/Minion-Shy-icon.png");
                    imageList.Add("/Resources/Minion-Superman-icon.png");
                }
                else
                {
                    imageList.Add("/Resources/Minion-Evil-2-icon.png");
                    imageList.Add("/Resources/Minion-Evil-3-icon.png");
                    imageList.Add("/Resources/Minion-Evil-4-icon.png");
                    imageList.Add("/Resources/Minion-Evil-icon.png");
                }

                return imageList.OrderBy(image => Guid.NewGuid()).First();
            }

            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
